﻿
myApp.controller("NewsDetailCtrl", function ($scope, $post, $http, $resource, $routeParams, $restUrls, $rootScope, $location) {

    $scope.item_id = $routeParams.id;




    var getDetail = function () {
        $resource($restUrls["getPage"] + '&id=:id').get({ id: $scope.item_id }).$promise.then(function (data) {

            $scope.item = data.data;

        });
    }


    getDetail();

    $scope.show_popup = false;
    $scope.message = "";
    $scope.comment = function () {
        $scope.show_popup = true;
    }
    $scope.send_comment = function () {


        $post($restUrls["commentPage"],
            {
                page_id: $scope.item_id,
                message: $scope.message
            })
            .success(function (result) {
                $scope.message = "";
                $scope.show_popup = false;
                getDetail();
            }).error(function (data, status, headers, config) {
            $scope.show_popup = false;
        });


    }

    $scope.close_comment = function () {
        $scope.show_popup = false;
        $scope.message = "";
    }

});
